package com.zhaojun.cloud.common.util;


import com.zhaojun.cloud.common.exception.AssertionException;

import java.util.List;


public abstract class AssertionEx extends Assertion {

    public static void isNegative(Short value, String message) {
        if (!Detect.isNegative(value)) {
            throw new AssertionException(message);
        }
    }


    public static void isPositive(Short value, String message) {
        if (!Detect.isPositive(value)) {
            throw new AssertionException(message);
        }
    }


    public static void isNegative(Integer value, String message) {
        if (!Detect.isNegative(value)) {
            throw new AssertionException(message);
        }
    }


    public static void isPositive(Integer value, String message) {
        if (!Detect.isPositive(value)) {
            throw new AssertionException(message);
        }
    }

    public static void isPositive(double value, String message) {
        if (!Detect.isPositive(value)) {
            throw new AssertionException(message);
        }
    }

    public static void isNegative(Long value, String message) {
        if (!Detect.isNegative(value)) {
            throw new AssertionException(message);
        }
    }

    public static void isNegative(double value, String message) {
        if (!Detect.isNegative(value)) {
            throw new AssertionException(message);
        }
    }

    public static void isPositive(Long value, String message) {
        if (!Detect.isPositive(value)) {
            throw new AssertionException(message);
        }
    }


    public static void isNegative(Float value, String message) {
        if (!Detect.isNegative(value)) {
            throw new AssertionException(message);
        }
    }


    public static void isPositive(Float value, String message) {
        if (!Detect.isPositive(value)) {
            throw new AssertionException(message);
        }
    }


    public static void isNegative(Double value, String message) {
        if (!Detect.isNegative(value)) {
            throw new AssertionException(message);
        }
    }


    public static void isPositive(Double value, String message) {
        if (!Detect.isPositive(value)) {
            throw new AssertionException(message);
        }
    }


    public static void notEmpty(String[] string, String message) {
        if (!Detect.notEmpty(string)) {
            throw new AssertionException(message);
        }
    }


    public static void notEmpty(long[] values, String message) {
        if (!Detect.notEmpty(values)) {
            throw new AssertionException(message);
        }
    }


    public static void notEmpty(List<?> list, String message) {
        if (!Detect.notEmpty(list)) {
            throw new AssertionException(message);
        }
    }


    public static void notEmpty(String string, String message) {
        if (!Detect.notEmpty(string)) {
            throw new AssertionException(message);
        }
    }


    public static void isEmpty(String[] string, String message) {
        if (Detect.notEmpty(string)) {
            throw new AssertionException(message);
        }
    }


    public static void isEmpty(long[] values, String message) {
        if (Detect.notEmpty(values)) {
            throw new AssertionException(message);
        }
    }


    public static void isEmpty(List<?> list, String message) {
        if (Detect.notEmpty(list)) {
            throw new AssertionException(message);
        }
    }


    public static void isEmpty(String string, String message) {
        if (Detect.notEmpty(string)) {
            throw new AssertionException(message);
        }
    }


    public static void onlyOne(List<?> list, String message) {
        if (!Detect.onlyOne(list)) {
            throw new AssertionException(message);
        }
    }

    public static void isTrue(boolean expression, String message) {
        if (!expression) {
            throw new AssertionException(message);
        }
    }

    public static void isFalse(boolean expression, String message) {
        if (expression) {
            throw new AssertionException(message);
        }
    }


    public static void state(boolean expression, String message) {
        if (!expression) {
            throw new AssertionException(message);
        }
    }


    public static void isNull(Object object, String message) {
        if (object != null) {
            throw new AssertionException(message);
        }
    }


    public static void notNull(Object object, String message) {
        if (object == null) {
            throw new AssertionException(message);
        }
    }

    /**
     * 断言是否是图片后缀
     */
    public static void isPictureSuffix(String pictureSuffix, String messaage) {
        if (!FileUtil.isPictureSuffix(pictureSuffix)) {
            throw new AssertionException(messaage);
        }
    }

}
